# 列表 取值-> 1.index 索引单个值 2.slice 切片取一值 还是一个·

# name = "Alex,Marry,jack"
# #    01234...
# name_list = ["Alex","Marry","jack"]
# #              0        1      2
# print(name[0:4])
# print(names_list[0])

# python中一切都是对象！
# 2. 列表增加
# 2.1 append() 增加元素到list的末尾
#     append()一般用来新建列表会用到
name_J = []
names = ["Mike","Mary","Jan","Jack"]
stu_成绩 = [97,95,93,95,92,96,92,95,100]

names.append("yt")
names.append("ruiqian")
for i in names:
    if i[0] == "J":
        names.J.append(i)
print("names_J=",name_J)
print(names)

# 2.2 insert() 插入元素
names.insert(2,"lihua")
print("插入lihua之后的names:",names)

# 3. 删除/移除
# 3.1 remove()使用remove之前，应该判断该元素是否存在该list之中
# print("ruiqian" in names)
# names_user = input("删除内容：")
# while True:
#     if names_user in names:
#        names.remove(names_user)
#     else:
#        break
# #  name.remove("ruiqian")
# print("remove之后的names："，names)

# 3.2 pop() 删除 pop()不填内容 对应记忆 ==> append() 删除末尾

# names.pop()
# print(names)

# 4. index()
# print(names.insert("ruiqian"))

# 5.sort()排序 默认从小到大排序 reverse = Fales(默认)  小-大
#                           reverse = True  大-小
stu_成绩.sort(reverse=True)
print(stu_成绩)
names。sort() # 字符串 以首字母按照ASCII编码表顺序排序
print(names)

# 6.count() 查看某元素的次数
print(sta_成绩.count(95))

7. clear()



# 8. extend() 是有顺序的， 操作哪一个列表，那一个列表先写
# names.extend(names_J)
# print(names)

